/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hibernate.model.dao;

import hibernate.util.HibernateUtil;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;

/**
 *
 * @author Administrator
 */
public class ThamSoDAO 
{
    //<editor-fold defaultstate="collapsed" desc="1. Lấy số sản phẩm tối đa trên trang chủ">
    public static int LaySoSanPhamTrenTrangChu()
    {
        int soLuong = 0;
        Session session = HibernateUtil.getSessionFactory().openSession();
        try
        {
            String hql = "select ts.soSanPhamTrenTrangChu from Thamso ts";
            Query query = session.createQuery(hql);
            Object ob = query.uniqueResult();
            soLuong = (Integer)ob;
        }catch(HibernateException ex)
        {
            System.out.println(ex);
        }
        return soLuong;
    }
    //</editor-fold>
 
}
